package com.api.syh56.shengyunhui.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.*;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.FieldDefaults;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;


@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
@TableName("waybill")
public class Waybill implements Serializable {


    @Column(name = "id",isKey = true,isAutoIncrement = true,comment = "运单id")
    private Long id;

    @Column(name = "waybill_number", isNull = false) // 运单号，不允许为空
    private String waybillNumber;

    @Column(name = "driver_id")// 司机ID
    private Long driverId;

    @Column(name = "shiper_id")// 货主ID
    private Long shiperId;

    @Column(name = "ship_address_id") // 发货地址id
    @ColumnComment("发货地址id")
    private Long shipAddressId;

    @Column(name = "receive_address_id") // 收货地址id
    @ColumnComment("收货地址id")
    private Long receiveAddressId;

    @Column(name = "goods_id")
    @ColumnComment("货物id")
    private Long goodsId;

    /**
     * 专线id
     */
    @Column(name = "dedicated_id")
    @ColumnComment("专线id")
    private Long dedicatedId;

    /**
     * 报价id
     */
    @Column(name = "quote_id")
    @ColumnComment("报价id")
    private Long quoteId;

    /**
     * 交货方式 1自送专线 2上门提货
     */
    @Column(name = "ship_delivery_method")
    @ColumnComment("交货方式 1自送专线 2上门提货")
    @DefaultValue("0")
    private short shipDeliveryMethod;

    /**
     * 配送方式 1送货上门 2自提
     */
    @Column(name = "receive_delivery_method")
    @ColumnComment("配送方式 1送货上门 2自提")
    @DefaultValue("0")
    private short receiveDeliveryMethod;

    /**
     * 付款方式 1寄付现结 2到付 3寄付月结
     */
    @Column(name = "pay_method")
    @ColumnComment("付款方式 1寄付现结 2到付 3寄付月结")
    @DefaultValue("0")
    private short payMethod;


    /**
     * 期望送达天数
     */
    @Column(name = "expected_delivery_days")
    @ColumnComment("期望送达天数")
    private int expectedDeliveryDays;
    /**
     * 期望配送时间
     */
    @Column(name = "expected_delivery_time")
    @ColumnComment("期望配送时间")
    private LocalDateTime expectedDeliveryTime;

    @Column(name = "quote_time")
    @ColumnComment("确认报价时间")
    private LocalDateTime quoteTime;

    @Column(name = "ship_time")
    @ColumnComment("发货时间")
    private LocalDateTime shipTime;

    @Column(name = "delivered_time")
    @ColumnComment("到达时间")
    private LocalDateTime deliveredTime;

    @Column(name = "settle_time")
    @ColumnComment("结算时间")
    private LocalDateTime settleTime;


    @Column(name = "waybill_status") // 订单状态
    @ColumnComment("订单状态")
    private short waybillStatus;

    @Column(name = "delivery_status") // 货物运输状态
    @ColumnComment("货物运输状态")
    @DefaultValue("0")
    private short deliveryStatus;

    @Column(name = "remark")
    private String remark;

    @Column(name = "is_touched") // 是否联系过货主
    @ColumnComment("是否联系过货主")
    @DefaultValue("0")
    private boolean isTouched;

    @Column(name = "cancel_reason") // 取消原因
    @ColumnComment("取消原因")
    private String cancelReason;

    @Column(name = "cancel_by")
    @ColumnComment("取消人 // 货主1 or 司机2")
    @DefaultValue("0")
    private int cancelBy;

    @Column(name = "return_deposit") // 是否可退定金
    @ColumnComment("是否可退定金")
    @DefaultValue("0")
    private boolean returnDeposit;

    @Column(name = "ship_company") // 发货公司
    private String shipCompany;

    @Column(name = "receive_company") // 收货公司
    private String receiveCompany;


    @Column(name = "is_receipt") // 是否收到货
    @ColumnComment("是否收到货")
    @DefaultValue("0")
    private boolean isReceipt;

    /**
     * 回单照片
     */
    @Column(name = "receipt_url")
    private String receiptUrl;

    /**
     * 货车当前位置（经纬度）
     */
    @Column(name = "current_location")
    @DefaultValue(value = "")
    private String currentLocation;


    @Column(name = "need_invoiced") // 是否需要开票
    @ColumnComment("是否需要开票")
    @DefaultValue("0")
    private boolean needInvoiced;

    @Column(name = "invoiced") // 是否已开票
    @ColumnComment("是否已开票")
    @DefaultValue("0")
    private boolean invoiced;




    @Column(name = "tax")
    @ColumnComment("税额")
    @DefaultValue("0")
    private BigDecimal tax;

    @Column(name = "offerend_minus_tax")
    @ColumnComment("开票金额")
    @DefaultValue("0")
    private BigDecimal offerendMinusTax;


    @Column(name = "deposit") // 定金
    @ColumnComment("定金")
    @DefaultValue("10")
    private BigDecimal deposit;

    @Column(name = "offer_init")
    @ColumnComment("服务费")
    @DefaultValue("0")
    private BigDecimal offerInit;

    @Column(name = "offer_end") // 运费
    @ColumnComment("运费")
    @DefaultValue("0")
    private BigDecimal offerEnd;

    @Column(name = "offer_all") //
    @ColumnComment("含税总额(服务费和运费)")
    @DefaultValue("0")
    private BigDecimal offerAll;

    @Column(name = "car_number",comment = "车牌号码")
    private String carNumber;

    @Column(name = "cuo_id",comment = "优惠券Id")
    private Long cuoId;

    /**
     * 实际支付金额
     */
    @Column(name = "act_amount",comment = "实际支付金额")
    @DefaultValue("0")
    private BigDecimal actAmount;

    @Column(name = "pay_time",comment = "支付时间")
    private LocalDateTime payTime;

    @Column(name = "eid",comment = "设备号")
    private String eid;

    @Column(name = "pay_type",comment = "支付金额类型")
    private Short payType;

    @Column(name = "waybill_lock",comment = "加锁")
    @DefaultValue("0")
    private Short waybillLock;

    /**
     * 车牌颜色(1 蓝色、2 黄色、3 黄绿色)
     */
    @Column(name = "card_color",comment = "车牌颜色")
    private String cardColor;

    @Column(name = "total_distance") // 总路程
    @DefaultValue("0")
    private double totalDistance;

    @Column(name = "offer_count") // 报价数量统计
    @DefaultValue("0")
    private int offerCount;

    /**
     * 订单完成时间
     */
    @Column(name = "finish_time")
    private LocalDateTime finishTime;

    @TableField(fill = FieldFill.INSERT)
    @Column(name = "creator_user_id") // 创建者用户ID
    private Long creatorUserId;

    @TableField(fill = FieldFill.INSERT)
    @Column(name = "creation_time") // 创建时间
    private LocalDateTime creationTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Column(name = "last_modifier_user_id") // 最后修改者用户ID
    private Long lastModifierUserId;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Column(name = "last_modification_time") // 最后修改时间
    private LocalDateTime lastModificationTime;

    @TableLogic
    @Column(name = "is_deleted") // 是否已删除
    @DefaultValue("false")
    private boolean isDeleted;


    /**
     * 发货市级区域编码
     */
    @Column(name = "ori_ad_code",comment = "发货市级区域编码")
    private Long oriAdCode;
    /**
     * 收货市级区域编码
     */
    @Column(name = "dst_ad_code",comment = "收货市级区域编码")
    private Long dstAdCode;

    @Column(name = "ori_and_dst_ad_code")
    private String oriAndDstAdCode;

    /**
     * 专线详细地址
     */
    @Column(name = "driver_location")
    private String driverLocation;

    /**
     * 提示次数
     */
    @Column(name = "send_times")
    @DefaultValue("0")
    private Integer sendTimes;
}